package de.mouseless.csv2sql.parsers;

import java.util.List;

import de.mouseless.csv2sql.model.Table;

public class TableParser extends AbstractParser {
   private List<List<String>> lines;
   private Table table;

   public TableParser(List<List<String>> linesForOneTable) {
      this.lines = linesForOneTable;
   }

   public void parseTable(ParserContext context) {
      Table table = null;
      for (List<String> line : lines) {
         if(line.size()==0 || line.get(0).startsWith("//")) {
            continue;
         }
         if(line.get(0).toLowerCase().equals("table")) {
            table = new Table(line.get(1).toUpperCase());
            context.getModel().addTable(table);
            context.setCurrentTable(table);
         }else {
            (new ColumnParser(line)).parseColumn(context);
         }
      }
   }

}
